﻿using GNSystem.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace GNSystem.Helpers
{
    public class User
    {

        const string NameTemplate = "<a href=\"/Account/View/{0}\"><span style=\"{1}\">{2}</span></a>";
        const string EmptyName = "<span style=\"color: gray;\">User Not Found</span>";
        public static MvcHtmlString UserName(UserProfile user, DataContext db)
        {
            if (user == null)
                new MvcHtmlString(EmptyName);
            string style = db.UserGroups.Find(user.GroupID).NameStyle;
            var str = new MvcHtmlString(string.Format(NameTemplate, user.UserId, style, user.UserName));
            return str;
        }
        public static MvcHtmlString UserName(int uid, DataContext db)
        {
            return UserName(db.UserProfiles.Find(uid), db);
        }
    }
}